package cn.wangxl.loglog.service;

import cn.wangxl.loglog.constants.Application;
import cn.wangxl.loglog.dao.MongoLogRepository;
import cn.wangxl.loglog.domain.BasicLogDO;
import cn.wangxl.loglog.qo.BasicQuery;
import cn.wangxl.loglog.qo.LogQuery;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Description TODO
 * @Classname LogService
 * @Created by wangxl
 * @Date 2020/5/7 23:27
 */
@Service
@Slf4j
public class LogService {

    @Resource
    MongoLogRepository mongoLogReposity;

    public void saveLog(BasicLogDO basicLogDO, Application application, String collectionName){
        mongoLogReposity.insert(basicLogDO,application,collectionName);
    }

    public void saveLog(List<BasicLogDO> basicLogDOList, Application application, String collectionName){
        mongoLogReposity.batchInsert(basicLogDOList,application,collectionName);
    }

    public void deleteLog(Integer id, Application application, String collectionName){
        mongoLogReposity.delete(id,application,collectionName);
    }

    public List<BasicLogDO> query(BasicQuery basicQuery, Application application, String collectionName){
        return mongoLogReposity.query1(basicQuery,application,collectionName);
    }

    public long count(BasicQuery basicQuery, Application application, String collectionName){
        return mongoLogReposity.count1(basicQuery,application,collectionName);
    }

}
